import { channelType } from "@/types/data"
import { ChannelAction } from "@/types/store"


export type channel={
 channels:channelType[],
 active:string,
 allchannel:channelType[]
}
const initialState={
    channels:[],
    active:'2',
    allchannel:[]
} as channel
// console.log(initialState,'initialState');
const Channel = (state = initialState, action:ChannelAction) => {
    switch(action.type){
        case 'channel/get_channel':
            return {...state,channels: action.payload}
        case 'channel/set_active':
            return {...state,active:action.payload}
        case 'channel/saveAllChannels':
            return {...state,allchannel:action.payload}
        case 'channel/addChannels':
            return {...state,channels:action.payload}
        default:
            return state
    }
    
}

export default Channel
